package com.svconnect.exceptions;

import com.svconnect.annotations.DataMember;

public class FaultException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	
	@DataMember(name="faultcode")
	private String faultcode;
	@DataMember(name="faultstring")
	private String faultstring;
	
	private IException detail;

	public FaultException(String faultcode, String faultstring) {
		super();
		this.faultcode = faultcode;
		this.faultstring = faultstring;
	}
	
	public String getFaultcode() {
		return faultcode;
	}
	public void setFaultcode(String faultcode) {
		this.faultcode = faultcode;
	}
	public String getFaultstring() {
		return faultstring;
	}
	public void setFaultstring(String faultstring) {
		this.faultstring = faultstring;
	}
	public IException getDetail() {
		return detail;
	}
	public void setDetail(IException detail) {
		this.detail = detail;
	}	
	
	@Override
	public String getMessage() {
		StringBuilder sb = new StringBuilder();
		if (faultcode!=null) { 
			sb.append(faultcode);
			sb.append("\n");
		}
		if (faultstring!=null) {
			sb.append(faultstring);
			sb.append("\n");
		}
		return sb.toString();
	}
}
